<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学生类别" prop="studentType">
        <el-select v-model="queryParams.studentType" placeholder="请选择学生类别" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="学制" prop="eduSystem">
        <el-input
          v-model="queryParams.eduSystem"
          placeholder="请输入学制"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入学就读学校" prop="startSchool">
        <el-input
          v-model="queryParams.startSchool"
          placeholder="请输入入学就读学校"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学院/系" prop="college">
        <el-input
          v-model="queryParams.college"
          placeholder="请输入学院/系"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专业" prop="profession">
        <el-input
          v-model="queryParams.profession"
          placeholder="请输入专业"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="就读学历" prop="degree">
        <el-input
          v-model="queryParams.degree"
          placeholder="请输入就读学历"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="就读学历代码" prop="degreeNo">
        <el-input
          v-model="queryParams.degreeNo"
          placeholder="请输入就读学历代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="就读学位" prop="science">
        <el-input
          v-model="queryParams.science"
          placeholder="请输入就读学位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="就读学位代码" prop="scienceNo">
        <el-input
          v-model="queryParams.scienceNo"
          placeholder="请输入就读学位代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学位类型" prop="scienceType">
        <el-select v-model="queryParams.scienceType" placeholder="请选择学位类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="学习方式" prop="studyType">
        <el-select v-model="queryParams.studyType" placeholder="请选择学习方式" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="学习方式代码" prop="studyTypeNo">
        <el-input
          v-model="queryParams.studyTypeNo"
          placeholder="请输入学习方式代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="培养方式" prop="cultureType">
        <el-select v-model="queryParams.cultureType" placeholder="请选择培养方式" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="培养方式代码" prop="cultureTypeNo">
        <el-input
          v-model="queryParams.cultureTypeNo"
          placeholder="请输入培养方式代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级" prop="class">
        <el-input
          v-model="queryParams.class"
          placeholder="请输入班级"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入学年度" prop="admissionTime">
        <el-input
          v-model="queryParams.admissionTime"
          placeholder="请输入入学年度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学号" prop="studentNo">
        <el-input
          v-model="queryParams.studentNo"
          placeholder="请输入学号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成绩单" prop="studentGrades">
        <el-input
          v-model="queryParams.studentGrades"
          placeholder="请输入成绩单"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="毕业证书号" prop="graduationNo">
        <el-input
          v-model="queryParams.graduationNo"
          placeholder="请输入毕业证书号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学位证书号" prop="diploma">
        <el-input
          v-model="queryParams.diploma"
          placeholder="请输入学位证书号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考生号" prop="examineeNo">
        <el-input
          v-model="queryParams.examineeNo"
          placeholder="请输入考生号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生源所在地" prop="examineePlace">
        <el-input
          v-model="queryParams.examineePlace"
          placeholder="请输入生源所在地"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生源所在地" prop="jobType">
        <el-select v-model="queryParams.jobType" placeholder="请选择生源所在地" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="生源所在地" prop="accountType">
        <el-select v-model="queryParams.accountType" placeholder="请选择生源所在地" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="生源所在地" prop="candidatesType">
        <el-select v-model="queryParams.candidatesType" placeholder="请选择生源所在地" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="生源所在地" prop="admitType">
        <el-select v-model="queryParams.admitType" placeholder="请选择生源所在地" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="生源所在地" prop="joinTime">
        <el-input
          v-model="queryParams.joinTime"
          placeholder="请输入生源所在地"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生源所在地" prop="outTime">
        <el-input
          v-model="queryParams.outTime"
          placeholder="请输入生源所在地"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生源所在地" prop="graduationConclusion">
        <el-input
          v-model="queryParams.graduationConclusion"
          placeholder="请输入生源所在地"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:roll:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:roll:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:roll:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:roll:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="rollList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="基本信息关联id" align="center" prop="alumneId" />
      <el-table-column label="基本信息关联id" align="center" prop="lbcode" />
      <el-table-column label="学生类别" align="center" prop="studentType" />
      <el-table-column label="学制" align="center" prop="eduSystem" />
      <el-table-column label="入学就读学校" align="center" prop="startSchool" />
      <el-table-column label="学院/系" align="center" prop="college" />
      <el-table-column label="专业" align="center" prop="profession" />
      <el-table-column label="就读学历" align="center" prop="degree" />
      <el-table-column label="就读学历代码" align="center" prop="degreeNo" />
      <el-table-column label="就读学位" align="center" prop="science" />
      <el-table-column label="就读学位代码" align="center" prop="scienceNo" />
      <el-table-column label="学位类型" align="center" prop="scienceType" />
      <el-table-column label="学习方式" align="center" prop="studyType" />
      <el-table-column label="学习方式代码" align="center" prop="studyTypeNo" />
      <el-table-column label="培养方式" align="center" prop="cultureType" />
      <el-table-column label="培养方式代码" align="center" prop="cultureTypeNo" />
      <el-table-column label="班级" align="center" prop="class" />
      <el-table-column label="入学年度" align="center" prop="admissionTime" />
      <el-table-column label="学号" align="center" prop="studentNo" />
      <el-table-column label="个人照片" align="center" prop="studentPhoto" />
      <el-table-column label="成绩单" align="center" prop="studentGrades" />
      <el-table-column label="毕业证书号" align="center" prop="graduationNo" />
      <el-table-column label="学位证书号" align="center" prop="diploma" />
      <el-table-column label="考生号" align="center" prop="examineeNo" />
      <el-table-column label="生源所在地" align="center" prop="examineePlace" />
      <el-table-column label="生源所在地" align="center" prop="jobType" />
      <el-table-column label="生源所在地" align="center" prop="accountType" />
      <el-table-column label="生源所在地" align="center" prop="candidatesType" />
      <el-table-column label="生源所在地" align="center" prop="admitType" />
      <el-table-column label="生源所在地" align="center" prop="joinTime" />
      <el-table-column label="生源所在地" align="center" prop="outTime" />
      <el-table-column label="生源所在地" align="center" prop="graduationConclusion" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:roll:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:roll:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="生源所在地" prop="id">
          <el-input v-model="form.id" placeholder="请输入生源所在地" />
        </el-form-item>
        <el-form-item label="学生类别" prop="studentType">
          <el-select v-model="form.studentType" placeholder="请选择学生类别">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="学制" prop="eduSystem">
          <el-input v-model="form.eduSystem" placeholder="请输入学制" />
        </el-form-item>
        <el-form-item label="入学就读学校" prop="startSchool">
          <el-input v-model="form.startSchool" placeholder="请输入入学就读学校" />
        </el-form-item>
        <el-form-item label="学院/系" prop="college">
          <el-input v-model="form.college" placeholder="请输入学院/系" />
        </el-form-item>
        <el-form-item label="专业" prop="profession">
          <el-input v-model="form.profession" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="就读学历" prop="degree">
          <el-input v-model="form.degree" placeholder="请输入就读学历" />
        </el-form-item>
        <el-form-item label="就读学历代码" prop="degreeNo">
          <el-input v-model="form.degreeNo" placeholder="请输入就读学历代码" />
        </el-form-item>
        <el-form-item label="就读学位" prop="science">
          <el-input v-model="form.science" placeholder="请输入就读学位" />
        </el-form-item>
        <el-form-item label="就读学位代码" prop="scienceNo">
          <el-input v-model="form.scienceNo" placeholder="请输入就读学位代码" />
        </el-form-item>
        <el-form-item label="学位类型" prop="scienceType">
          <el-select v-model="form.scienceType" placeholder="请选择学位类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="学习方式" prop="studyType">
          <el-select v-model="form.studyType" placeholder="请选择学习方式">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="学习方式代码" prop="studyTypeNo">
          <el-input v-model="form.studyTypeNo" placeholder="请输入学习方式代码" />
        </el-form-item>
        <el-form-item label="培养方式" prop="cultureType">
          <el-select v-model="form.cultureType" placeholder="请选择培养方式">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="培养方式代码" prop="cultureTypeNo">
          <el-input v-model="form.cultureTypeNo" placeholder="请输入培养方式代码" />
        </el-form-item>
        <el-form-item label="班级" prop="class">
          <el-input v-model="form.class" placeholder="请输入班级" />
        </el-form-item>
        <el-form-item label="入学年度" prop="admissionTime">
          <el-input v-model="form.admissionTime" placeholder="请输入入学年度" />
        </el-form-item>
        <el-form-item label="学号" prop="studentNo">
          <el-input v-model="form.studentNo" placeholder="请输入学号" />
        </el-form-item>
        <el-form-item label="成绩单" prop="studentGrades">
          <el-input v-model="form.studentGrades" placeholder="请输入成绩单" />
        </el-form-item>
        <el-form-item label="毕业证书号" prop="graduationNo">
          <el-input v-model="form.graduationNo" placeholder="请输入毕业证书号" />
        </el-form-item>
        <el-form-item label="学位证书号" prop="diploma">
          <el-input v-model="form.diploma" placeholder="请输入学位证书号" />
        </el-form-item>
        <el-form-item label="考生号" prop="examineeNo">
          <el-input v-model="form.examineeNo" placeholder="请输入考生号" />
        </el-form-item>
        <el-form-item label="生源所在地" prop="examineePlace">
          <el-input v-model="form.examineePlace" placeholder="请输入生源所在地" />
        </el-form-item>
        <el-form-item label="生源所在地" prop="jobType">
          <el-select v-model="form.jobType" placeholder="请选择生源所在地">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="生源所在地" prop="accountType">
          <el-select v-model="form.accountType" placeholder="请选择生源所在地">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="生源所在地" prop="candidatesType">
          <el-select v-model="form.candidatesType" placeholder="请选择生源所在地">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="生源所在地" prop="admitType">
          <el-select v-model="form.admitType" placeholder="请选择生源所在地">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="生源所在地" prop="joinTime">
          <el-input v-model="form.joinTime" placeholder="请输入生源所在地" />
        </el-form-item>
        <el-form-item label="生源所在地" prop="outTime">
          <el-input v-model="form.outTime" placeholder="请输入生源所在地" />
        </el-form-item>
        <el-form-item label="生源所在地" prop="graduationConclusion">
          <el-input v-model="form.graduationConclusion" placeholder="请输入生源所在地" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRoll, getRoll, delRoll, addRoll, updateRoll, exportRoll } from "@/api/system/roll";

export default {
  name: "Roll",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      rollList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        studentType: null,
        eduSystem: null,
        startSchool: null,
        college: null,
        profession: null,
        degree: null,
        degreeNo: null,
        science: null,
        scienceNo: null,
        scienceType: null,
        studyType: null,
        studyTypeNo: null,
        cultureType: null,
        cultureTypeNo: null,
        class: null,
        admissionTime: null,
        studentNo: null,
        studentPhoto: null,
        studentGrades: null,
        graduationNo: null,
        diploma: null,
        examineeNo: null,
        examineePlace: null,
        jobType: null,
        accountType: null,
        candidatesType: null,
        admitType: null,
        joinTime: null,
        outTime: null,
        graduationConclusion: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "生源所在地不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listRoll(this.queryParams).then(response => {
        this.rollList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        alumneId: null,
        lbcode: null,
        studentType: null,
        eduSystem: null,
        startSchool: null,
        college: null,
        profession: null,
        degree: null,
        degreeNo: null,
        science: null,
        scienceNo: null,
        scienceType: null,
        studyType: null,
        studyTypeNo: null,
        cultureType: null,
        cultureTypeNo: null,
        class: null,
        admissionTime: null,
        studentNo: null,
        studentPhoto: null,
        studentGrades: null,
        graduationNo: null,
        diploma: null,
        examineeNo: null,
        examineePlace: null,
        jobType: null,
        accountType: null,
        candidatesType: null,
        admitType: null,
        joinTime: null,
        outTime: null,
        graduationConclusion: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.alumneId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const alumneId = row.alumneId || this.ids
      getRoll(alumneId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改【请填写功能名称】";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.alumneId != null) {
            updateRoll(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRoll(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const alumneIds = row.alumneId || this.ids;
      this.$confirm('是否确认删除【请填写功能名称】编号为"' + alumneIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delRoll(alumneIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有【请填写功能名称】数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportRoll(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    }
  }
};
</script>
